<?php
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST,GET,PUT,DELETE');
header('Access-Control-Allow-Headers:x-requested-with,Content-Type,X-CSRF-Token');


// header("content-type:text/html;charset=utf-8");
$userid = $_REQUEST["userid"];  //用户名
$userpw =$_REQUEST["userpw"]; //密码
$size = $_REQUEST["size"]; //手机号码
$email = $_REQUEST["email"]; //邮箱

// 1. 连接数据库
$mysqli = new Mysqli("localhost", "root", "root", "db_jiuji");;
// mysqli_query($mysqli,"set names 'utf8'");// 解决数据库查询乱码问题
// 2. 判断数据库是否连接成功
$mysqli->connect_errno;
if ($mysqli->connect_errno) {
    die();
};
//
$sql = "select *from user where dl_cellphone='{$size}'";
$result = $mysqli->query($sql);
$sqli = "INSERT INTO user (dl_name,dl_password,dl_cellphone,dl_email)
value('{$userid}','{$userpw}','{$size}','{$email}')";
if ($result->num_rows) {
    echo "0";
} else {
    $mysqli->query($sqli);
    echo "1";
}
